import {Controller, Get, Post, Body, Patch, Param, Delete, ParseUUIDPipe} from '@nestjs/common';
import { RemarkService } from './remark.service';
import { CreateRemarkDto } from './dto/create-remark.dto';
import { UpdateRemarkDto } from './dto/update-remark.dto';
import {reMarkEntity} from "./entities/remark.entity";

@Controller('remark')
export class RemarkController {
  constructor(private readonly remarkService: RemarkService) {}

  @Post()
  async create(@Body() createRemarkDto: CreateRemarkDto) {
    return new reMarkEntity(await this.remarkService.create(createRemarkDto));
  }

  @Get()
  async findAll():Promise<reMarkEntity[]> {
    const reMarks =await this.remarkService.findAll();
    return reMarks.map((reMark) => new reMarkEntity(reMark));
  }

  @Get(':id')
  async findOne(@Param('id',ParseUUIDPipe) id: string) {
    return new reMarkEntity(await this.remarkService.findOne(id));
  }

  @Patch(':id')
  async update(@Param('id',ParseUUIDPipe) id: string, @Body() updateRemarkDto: UpdateRemarkDto) {
    return new reMarkEntity(await this.remarkService.update(id, updateRemarkDto.mark));
  }

  @Delete(':id')
  async remove(@Param('id',ParseUUIDPipe) id: string) {
    return new reMarkEntity(await this.remarkService.remove(id));
  }
}
